// JavaScript Document
var imageUrl='http://static.ku123.com';  //CDN图片前缀
var initInput = 0;
function $(id)
{
    return document.getElementById(id);
}

var MainInfo={
    "isEnterRoom":false
};

 var arrLiveLevel=new Array();
arrLiveLevel[1]={};
arrLiveLevel[1].credit=0;
arrLiveLevel[1].x=50;
arrLiveLevel[1].y=0;
arrLiveLevel[2]={};
arrLiveLevel[2].credit=50000;
arrLiveLevel[2].x=50;
arrLiveLevel[2].y=20;
arrLiveLevel[3]={};
arrLiveLevel[3].credit=170000;
arrLiveLevel[3].x=50;
arrLiveLevel[3].y=40;
arrLiveLevel[4]={};
arrLiveLevel[4].credit=420000;
arrLiveLevel[4].x=50;
arrLiveLevel[4].y=60;
arrLiveLevel[5]={};
arrLiveLevel[5].credit=820000;
arrLiveLevel[5].x=50;
arrLiveLevel[5].y=80;
arrLiveLevel[6]={};
arrLiveLevel[6].credit=1520000;
arrLiveLevel[6].x=50;
arrLiveLevel[6].y=100;
arrLiveLevel[7]={};
arrLiveLevel[7].credit=3220000;
arrLiveLevel[7].x=50;
arrLiveLevel[7].y=120;
arrLiveLevel[8]={};
arrLiveLevel[8].credit=6220000;
arrLiveLevel[8].x=50;
arrLiveLevel[8].y=140;
arrLiveLevel[9]={};
arrLiveLevel[9].credit=9820000;
arrLiveLevel[9].x=50;
arrLiveLevel[9].y=160;
arrLiveLevel[10]={};
arrLiveLevel[10].credit=14720000;
arrLiveLevel[10].x=50;
arrLiveLevel[10].y=180;

arrLiveLevel[11]={};
arrLiveLevel[11].credit=20620000;
arrLiveLevel[11].x=50;
arrLiveLevel[11].y=200;
arrLiveLevel[12]={};
arrLiveLevel[12].credit=28420000;
arrLiveLevel[12].x=50;
arrLiveLevel[12].y=220;
arrLiveLevel[13]={};
arrLiveLevel[13].credit=38420000;
arrLiveLevel[13].x=50;
arrLiveLevel[13].y=240;
arrLiveLevel[14]={};
arrLiveLevel[14].credit=58420000;
arrLiveLevel[14].x=50;
arrLiveLevel[14].y=260;
arrLiveLevel[15]={};
arrLiveLevel[15].credit=94420000;
arrLiveLevel[15].x=50;
arrLiveLevel[15].y=280;
arrLiveLevel[16]={};
arrLiveLevel[16].credit=154420000;
arrLiveLevel[16].x=50;
arrLiveLevel[16].y=300;
arrLiveLevel[17]={};
arrLiveLevel[17].credit=224420000;
arrLiveLevel[17].x=50;
arrLiveLevel[17].y=320;
arrLiveLevel[18]={};
arrLiveLevel[18].credit=344420000;
arrLiveLevel[18].x=50;
arrLiveLevel[18].y=340;
arrLiveLevel[19]={};
arrLiveLevel[19].credit=484420000;
arrLiveLevel[19].x=50;
arrLiveLevel[19].y=360;
arrLiveLevel[20]={};
arrLiveLevel[20].credit=644420000;
arrLiveLevel[20].x=50;
arrLiveLevel[20].y=380;
arrLiveLevel[21]={};
arrLiveLevel[21].credit=824420000;
arrLiveLevel[21].x=50;
arrLiveLevel[21].y=400;
arrLiveLevel[22]={};
arrLiveLevel[22].credit=1024420000;
arrLiveLevel[22].x=50;
arrLiveLevel[22].y=420;
arrLiveLevel[23]={};
arrLiveLevel[23].credit=1244420000;
arrLiveLevel[23].x=50;
arrLiveLevel[23].y=440;
arrLiveLevel[24]={};
arrLiveLevel[24].credit=1484420000;
arrLiveLevel[24].x=50;
arrLiveLevel[24].y=460;
arrLiveLevel[25]={};
arrLiveLevel[25].credit=1744420000;
arrLiveLevel[25].x=50;
arrLiveLevel[25].y=480;


var arrWealthLevel=new Array();
arrWealthLevel[1]={};
arrWealthLevel[1].credit=1;
arrWealthLevel[1].x=0;
arrWealthLevel[1].y=0;
arrWealthLevel[2]={};
arrWealthLevel[2].credit=50001;
arrWealthLevel[2].x=0;
arrWealthLevel[2].y=20;
arrWealthLevel[3]={};
arrWealthLevel[3].credit=250001;
arrWealthLevel[3].x=0;
arrWealthLevel[3].y=40;
arrWealthLevel[4]={};
arrWealthLevel[4].credit=650001;
arrWealthLevel[4].x=0;
arrWealthLevel[4].y=60;
arrWealthLevel[5]={};
arrWealthLevel[5].credit=1450001;
arrWealthLevel[5].x=0;
arrWealthLevel[5].y=80;
arrWealthLevel[6]={};
arrWealthLevel[6].credit=2450000;
arrWealthLevel[6].x=0;
arrWealthLevel[6].y=100;
arrWealthLevel[7]={};
arrWealthLevel[7].credit=5450000;
arrWealthLevel[7].x=0;
arrWealthLevel[7].y=120;
arrWealthLevel[8]={};
arrWealthLevel[8].credit=10450000;
arrWealthLevel[8].x=0;
arrWealthLevel[8].y=140;
arrWealthLevel[9]={};
arrWealthLevel[9].credit=20450000;
arrWealthLevel[9].x=0;
arrWealthLevel[9].y=160;
arrWealthLevel[10]={};
arrWealthLevel[10].credit=35450000;
arrWealthLevel[10].x=0;
arrWealthLevel[10].y=180;
arrWealthLevel[11]={};
arrWealthLevel[11].credit=55450000;
arrWealthLevel[11].x=0;
arrWealthLevel[11].y=200;
arrWealthLevel[12]={};
arrWealthLevel[12].credit=105450000;
arrWealthLevel[12].x=0;
arrWealthLevel[12].y=220;
arrWealthLevel[13]={};
arrWealthLevel[13].credit=175450000;
arrWealthLevel[13].x=0;
arrWealthLevel[13].y=240;

arrWealthLevel[14]={};
arrWealthLevel[14].credit=265450000;
arrWealthLevel[14].x=0;
arrWealthLevel[14].y=260;
arrWealthLevel[15]={};
arrWealthLevel[15].credit=375450000;
arrWealthLevel[15].x=0;
arrWealthLevel[15].y=280;

arrWealthLevel[16]={};
arrWealthLevel[16].credit=525450000;
arrWealthLevel[16].x=0;
arrWealthLevel[16].y=300;
arrWealthLevel[17]={};
arrWealthLevel[17].credit=725450000;
arrWealthLevel[17].x=0;
arrWealthLevel[17].y=320;
arrWealthLevel[18]={};
arrWealthLevel[18].credit=975450000;
arrWealthLevel[18].x=0;
arrWealthLevel[18].y=340;
arrWealthLevel[19]={};
arrWealthLevel[19].credit=1275450000;
arrWealthLevel[19].x=0;
arrWealthLevel[19].y=360;
arrWealthLevel[20]={};
arrWealthLevel[20].credit=1655450000;
arrWealthLevel[20].x=0;
arrWealthLevel[20].y=380;

arrWealthLevel[21]={};
arrWealthLevel[21].credit=2135450000;
arrWealthLevel[21].x=0;
arrWealthLevel[21].y=400;
arrWealthLevel[22]={};
arrWealthLevel[22].credit=2735450000;
arrWealthLevel[22].x=0;
arrWealthLevel[22].y=420;
arrWealthLevel[23]={};
arrWealthLevel[23].credit=3535450000;
arrWealthLevel[23].x=0;
arrWealthLevel[23].y=440;
arrWealthLevel[24]={};
arrWealthLevel[24].credit=4535450000;
arrWealthLevel[24].x=0;
arrWealthLevel[24].y=460;
arrWealthLevel[25]={};
arrWealthLevel[25].credit=6035450000;
arrWealthLevel[25].x=0;
arrWealthLevel[25].y=480;

var arrWealthImagePosition=new Array();

function GetLevelByCredit(credit,arrObj)
{
    if (typeof(credit) == "undefined") {
        return 0;
    }
    var count=arrObj.length;
    var result=0;
    for(var i=1;i<count+1;i++)
    {
        if(arrObj[i])
        {
            if(arrObj[i].credit>credit)
            {
                break;
            }
            else
            {
                result=i;
            }
        }
       
    }
    return result;
}
function GetNextLevelCredit(level,arrObj)
{
    if(level<arrObj.length)
    {
        if(arrObj[level+1])
        {
            return arrObj[level+1].credit;
        }
        else
        {
            return  arrObj[level].credit;
        }
     
    }
    else
    {
        return  arrObj[level].credit;
    }
}

function displayChildMenu(obj)
{

    var arrChilds=obj.parentNode.getElementsByTagName("dd");
    if(arrChilds && arrChilds.length>0)
    {
        for(var i=0;i<arrChilds.length;i++)
        {
            if(arrChilds[i].style.display=="none")
            {
                arrChilds[i].style.display=""; 
            }
            else
            {
                arrChilds[i].style.display="none"; 
            }
			
        }
    }
}

function ChangeTabDiv(id)
{
	jQuery("li[id^='settab-star']").removeClass("on");
	jQuery("#settab-star"+id).addClass("on");
    var length=4;
    for(var i=1;i<=length;i++)
    {
		var obj=document.getElementById("dvrankhead"+i);
        if(i==id)
        {

            AddClassName(obj,"current");
            AddClassName($("dvrankstar"+i),"rank-list f14");
        }
		
        else
        {
            AddClassName(obj,"");
            AddClassName($("dvrankstar"+i),"rank-list f14 none");
        }
		
		
    }
}

function ChangeTabRegalDiv(id)
{
	jQuery("li[id^='settab-wealth']").removeClass("on");
	jQuery("#settab-wealth"+id).addClass("on");
    var length=4;
    for(var i=1;i<=length;i++)
    {
        var obj=document.getElementById("dvrankheadregal"+i);
        if(i==id)
        {
            //AddClassName(obj,"current");
            AddClassName($("dvrankregal"+i),"rank-list f14");
        }	
        else
        {
            AddClassName(obj,"");
            AddClassName($("dvrankregal"+i),"rank-list f14 none");
        }
		
		
    }
}

function ChangeTabPopulDiv(id) {
	jQuery("li[id^='settab-hot']").removeClass("on");
	jQuery("#settab-hot"+id).addClass("on");
    var length=4;
    for(var i=1;i<=length;i++)
    {
        var obj=document.getElementById("dvrankheadpopul"+i);
        if(i==id)
        {
            //AddClassName(obj,"current");
            AddClassName($("dvrankpopul"+i),"rank-list f14");
        }	
        else
        {
            AddClassName(obj,"");
            AddClassName($("dvrankpopul"+i),"rank-list f14 none");
        }
		
		
    }
}


function ChangeAdv(id,count)
{
    for(var i=0;i<count;i++)
    {
        var obj=document.getElementById("iconimage"+i);
        if(i==id)
        {
			
          AddClassName(obj,"on");
        }
		
        else
        {
          AddClassName(obj,"");
        }
		
		
    }
	
	$("ulindexadv").style.top=(-87*id)+"px"
}

function DeleteLookRecord(obj,rid)
{
	/// 优化	by niugh
	jQuery.getJSON(
			"index_ajax.php?action=100004&rid="+rid+"&randID="+Math.random(),
			function(objData){
				if(objData.confirm==100)
	            {
					var parent=obj.parentNode;
					var ppnode=parent.parentNode;
					parent.removeChild(obj);
					parent.parentNode.removeChild(parent);
					
					if(ppnode.childNodes.length==0)
					{
						ppnode.parentNode.removeChild(ppnode);
						AddClassName($("hidelookrecord"),"c9");
					}

	            }
			}
	);
}

function CloseLogin()
{
	
	var referrTag = getCookie("referrTag");
	
	if(referrTag.search(/YRT_/) == -1) {
		var objUser=$("loginusername");
		var pas=$("loginpassword");
		var objRegUser = $("regemail");
		var regpas=$("regpassword");
		var regrepas=$("regrepassword");
		
		if(objUser)
		{
			objUser.value = "请输入邮箱";
		}
		if(pas)
		{
			pas.value = "";
		}
		if(objRegUser) {
			objRegUser.value = "请使用您常用的邮箱";
		}
		if(regpas) {
			regpas.value = "";
		}
		if(regrepas) {
			regrepas.value = "";
		}
		
		$("logerrormsg").innerHTML = "";
		$("spregemailerror").style.display = "none";
		$("spregpassworderror").style.display = "none";
		$("sprepassworderror").style.display = "none";
		$("spregpasswordok").style.display = "none";
		$("sprepassworderror").style.display = "none";
		
		if(document.getElementById("mailBox_register") != null && document.getElementById("mailBox_register").style.display == "block") {
	    	document.getElementById("mailBox_register").style.display = "none";
	    }
	    
	    if(document.getElementById("mailBox_div_login") != null && document.getElementById("mailBox_div_login").style.display == "block") {
	    	document.getElementById("mailBox_div_login").style.display = "none";
	    }
	    
	    if(document.getElementById("close_input_div_login") != null && document.getElementById("close_input_div_login").style.display == "inline") {
	    	document.getElementById("close_input_div_login").style.display = "none";
	    }
	    
	    if(document.getElementById("close_input_register") != null && document.getElementById("close_input_register").style.display == "inline") {
	    	document.getElementById("close_input_register").style.display = "none";
	    }
		
	    document.getElementById("loginBox").style.display="none";
	    document.getElementById("loginMask").style.display="none";
	    document.getElementById("loginMaskBg").style.display="none";
	}
	else {/// 易瑞通广告平台
		document.getElementById("loginBox").style.display="none";
	}
	
	if(typeof(objRoom)=='undefined')
	{
	}
	else if(objRoom && objRoom.uid>0)
	{
		timeAutoOpen=setTimeout(function()
		{
			OpenRegister();
			if(intLoginAlertTime>15000 && intLoginAlertTime<40000)
			{
				intLoginAlertTime=15000
			}
			else if(intLoginAlertTime>10000)
			{
				intLoginAlertTime=10000;
			}
		},intLoginAlertTime);
	}
}

function CloseRegister()
{
	var objUser=$("loginusername");
	var pas=$("loginpassword");
	if(objUser)
	{
		objUser.value="";
	}
	if(pas)
	{
		pas.value="";
	}
    document.getElementById("registerBox").style.display="none";
    document.getElementById("loginMask").style.display="none";
    document.getElementById("loginMaskBg").style.display="none";
	
	if(typeof(objRoom)=='undefined')
	{
	}
	else if(objRoom && objRoom.uid>0)
	{
		timeAutoOpen=setTimeout(function()
		{
			OpenRegister();
			if(intLoginAlertTime>15000 && intLoginAlertTime<40000)
			{
				intLoginAlertTime=15000
			}
			else if(intLoginAlertTime>10000)
			{
				intLoginAlertTime=10000;
			}
		},intLoginAlertTime);
	}
}

function OnlyNum(obj)
{
    if(obj && obj.value)
    {
        obj.value=obj.value.replace(/\D+/,0);
    }
}

function CheckUserLength(obj,minLength,maxLength)
{
    if(trimStr(obj.value).length>=minLength && trimStr(obj.value).length<=maxLength)
    {
        return true;	
    }
    else
    {
        alert("password must be 4-20 characters");
        return false;
    }
}

function CheckLength(obj,len)
{
    if(obj && obj.value)
    {
        if(GetChatLength(trimStr(obj.value))>=len+0)
        {
            return true;	
        }
    }	
    return false
}


function PasswordBlur(obj,id)
{
	if(trimStr(obj.value).length<1)
	{
		
		$("sp"+id+"passworderror").innerHTML='<img src="'+imageUrl+'/img/error.gif" alt="">请输入密码';
		$("sp"+id+"passwordok").style.display="none";
		$("sp"+id+"passworderror").style.display="";

        return false;
	}
    if(!CheckLength(obj,6))
    {
		$("sp"+id+"passworderror").innerHTML='<img src="'+imageUrl+'/img/error.gif" alt="">密码长度为6-12位';
		$("sp"+id+"passwordok").style.display="none";
		$("sp"+id+"passworderror").style.display="";
        return false;
    }
    else
    {

		$("sp"+id+"passworderror").style.display="none";
		$("sp"+id+"passwordok").style.display="";
    }
    return true;
}

function confirmPasswordBlur(objPassword,obj)
{
    if(obj && objPassword)
    {

        if(trimStr(objPassword.value)!=trimStr(obj.value))
        {
		   $("sprepasswordok").style.display="none";
		   $("sprepassworderror").style.display="";
            return false;
        }
        else
        {
			$("sprepasswordok").style.display="";
		   	$("sprepassworderror").style.display="none";
        }
    }
    return true;
}

function CheckEmail(obj)
{
	
    var rep=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/gi;
    if(!rep.test(trimStr(obj.value)))
    {
        CreateDiv(obj.parentNode,"无效的邮箱");
        return false;
    }
    else
    {
        var strFlag=obj.parentNode.getAttribute("flag");
        if(strFlag && document.getElementById(strFlag) && document.getElementById(strFlag).parentNode)
        {
            obj.parentNode.removeChild(document.getElementById(strFlag));
        }
    }
    
    checkUserName(document.getElementById('username'));
    return true;
}

function CheckEmailNew(obj)
{
	if(obj.value.length>0 && obj.value!="请使用您常用的邮箱")
	{
		var rep=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/i;
		if(!rep.test(trimStr(obj.value)))
		{
			return false;
		}
	}
    return true;
}

function CheckNull(obj,content)
{
	
    if(obj)
    {
        if(trimStr(obj.value).length==0)
        {
            CreateDiv(obj.parentNode,content);
            return false;
        }
        else
        {
            var strFlag=obj.parentNode.getAttribute("flag");
            if(strFlag && document.getElementById(strFlag))
            {
                obj.parentNode.removeChild(document.getElementById(strFlag));
            }
        }
    }
    return true;
}

function RemoveDiv(obj)
{
    var strFlag=obj.parentNode.getAttribute("flag");
    if(strFlag && document.getElementById(strFlag))
    {
        obj.parentNode.removeChild(document.getElementById(strFlag));
    }
}

function RegisterFormSumbit(objUser,objWord)
{
	var bol=true;
	if(trimStr(objUser.value).length<1 || trimStr(objUser.value)=="请输入您的常用邮箱")
	{
		$("spregemailerror").innerHTML='请输入邮箱';
		$("spregemailerror").style.display="";
		$("spregemailok").style.display="none";
		return ;
	}
	
	if(!EmailBlur(objUser,"reg"))
	{
		bol=false;
	}
	if(!PasswordBlur(objWord,"reg") )
	{
		bol=false;
	}
        
    if( bol && confirmPasswordBlur(objWord,$("regrepassword")))
    {
        var username=objUser.value;
        var password=objWord.value;
		
		if(!$("login-agree").checked)
		{
			AlertDiv('您必须同意用户协议才能注册');
			return;
		}
		
		jQuery.getJSON(
				"index_ajax.php?action=200001&username="+trimStr(username)+"&password="+password+"&sessimg="+$("sessimg").value+"&randID="+Math.random(),
				function(objData){
					if(objData.confirm==10)
		            {
		                $("recode").style.visibility = "";
		                AddClassName($("sessimg"),'fl ibs ibs-focus');
		                setTextColor($("sessimg"),'#333333');
		                return false;
		            }
		            else if(objData.confirm==1)
		            {
		                AlertDiv("验证码错误");
						$("imgauthcode").src = './application/libraries/sessimg.php?type=register&rand='+new Date().getTime();
		                AddClassName($("sessimg"),'fl ibs ibs-focus');
		                setTextColor($("sessimg"),'#333333');
		            }
		            else if(objData.confirm==2)
		            {
		                AlertDiv("邮箱格式错误");
		            }
		            else if(objData.confirm==3)
		            {
		                AlertDiv("密码长度应该在6-20个之间");
		            }
		            else if(objData.confirm==4)
		            {
		                AlertDiv("注册失败，请稍后再试");	
		            }
					else if(objData.confirm==5)
					{
						objUser.value="";
						objWord.value="";
						$("regrepassword").value="";
						AlertDiv("用户名已存在");
						objUser.focus();
					}
					else if(objData.confirm==6)
					{
						AlertDiv("密码输入错误超过5次,请半小时以后再试!");
					}
					else if(objData.confirm==7)
		            {
		                    AlertDiv("你今天注册次数过多，请明天再试!");
		            }
		            else if(objData.confirm==100)
		            {
		            	location.href = location.href.replace(/#+/,"");
		            //CloseRegister();
							
		            //DisplayPersonInfo(objData.data);
		            }
		            else if(objData.confirm==9){
		            	AlertDiv("您的IP已经被锁定！");
		            }
				}
		);
    }
}
function ModifyFormSumbit(form)
{
    if(CheckEmail(document.getElementById('email')) && CheckNull(document.getElementById('company'),'Not valid company'))
    {
        form.submit();
    }
}

function LoginFormSumbit(objUser,objPassword,isindex)
{
	var error_num = getCookie('len'); 
	
	var auth_code = ''; //验证码

	if(isindex!=1)
	{

		if(trimStr(objUser.value).length<1 || objUser.value=="请输入邮箱")
		{
			$("logerrormsg").innerHTML='请输入邮箱';
			udp_login_fail();
			return false;
		}

		auth_code = document.getElementById('loginsessimg').value;

		if (error_num > 2 && auth_code.length != 4)
		{
			$("logerrormsg").innerHTML='请输入4位验证码';
			udp_login_fail();
			AddClassName($("loginsessimg"),'fl ibs ibs-focus');
            setTextColor($("loginsessimg"),'#333333');
			return false;
		}

		if(trimStr(objPassword.value).length<1 )
		{
			$("logerrormsg").innerHTML='请输入密码';
			udp_login_fail();
			return false;
		}
		
		$("logerrormsg").innerHTML="";
			var is9=0;
			if($("cbsavepassword").checked)
			{
				is9=1;
			}
			
			jQuery.getJSON(
					"index_ajax.php?action=200002&username="+objUser.value+"&password="+objPassword.value+"&auth_code="+auth_code+"&type="+is9+"&randID="+Math.random(),
					function(objData){
						if (objData.login_error_num > 2)
						{
							document.getElementById('logincode').style.display = "block";
						}

						if(objData.confirm==1)
						{
							objPassword.value="";
							$("logerrormsg").innerHTML="邮箱或密码有误";
							udp_login_fail();
						}else if (objData.confirm == 11)
						{
							$("logerrormsg").innerHTML="验证码输入有误";
							AddClassName($("loginsessimg"),'fl ibs ibs-focus');
							setTextColor($("loginsessimg"),'#333333');
							udp_login_fail();
						}
						else if(objData.confirm==2)
						{
							objPassword.value="";
							$("logerrormsg").innerHTML="你密码错误了5次，请30分钟以后再试试";
							udp_login_fail();
						}
						else if(objData.confirm==3)
						{
							objPassword.value="";
							$("logerrormsg").innerHTML="你的账号被锁定，请联系客服解锁";
						}
						else if(objData.confirm==100)
						{
							location.href=location.href.replace(/#+/,"");
						}
						else if(objData.confirm==9){
							alert('您的IP已经被锁定！');
		            	}
					}
			);
	}
	else
	{
		auth_code = document.getElementById('auth_code').value;

		if (error_num > 2 && auth_code.length != 4)
		{
			$("dvindexloginerrorinfo").innerHTML='请输入4位验证码';
			udp_login_fail();
			return false;
		}

		if(trimStr(objUser.value).length==0)
		{
			$("dvindexloginerrorinfo").innerHTML="请输入邮箱";
			udp_login_fail();
			return;
		}
		if(trimStr(objPassword.value).length==0)
		{
			$("dvindexloginerrorinfo").innerHTML="请输入密码";
			udp_login_fail();
			return;
		}
		var is10=0;
			if($("cbindexlogin").checked)
			{
				is10=1;
			}
			
			
		jQuery.getJSON(
				"index_ajax.php?action=200002&username="+objUser.value+"&password="+objPassword.value+"&auth_code="+auth_code+"&type="+is10+"&randID="+Math.random(),
				function(objData){
					if (objData.login_error_num == 3)
					{
						document.getElementById('index_login_code').style.display = "block";

						document.getElementById('login_info').className = document.getElementById('login_info').className + " codecheck";
					}

					if(objData.confirm==1)
					{
						objPassword.value="";
						$("dvindexloginerrorinfo").innerHTML="邮箱或密码错误";
						udp_login_fail();
					}
					else if(objData.confirm==2)
					{
						objPassword.value="";
						$("dvindexloginerrorinfo").innerHTML='囧！错误太多，想30分钟';
						udp_login_fail();
					}else if (objData.confirm == 11)
					{
						$("dvindexloginerrorinfo").innerHTML="验证码输入有误";
						udp_login_fail();
					}
					else if(objData.confirm==3)
					{
						objPassword.value="";
						$("dvindexloginerrorinfo").innerHTML="你的账号被锁定，请联系客服解锁";
					}
					else if(objData.confirm==100)
					{
						location.href=location.href.replace(/#+/,"");
					}
					else if(objData.confirm==9){
						alert('您的IP已经被锁定！');
	            	}
				}
		);
	
	}

}

function ChangePasswordSumbit(form)
{
    if(PasswordBlur(document.getElementById('old_password')) && PasswordBlur(document.getElementById('new_password')) && confirmPasswordBlur(document.getElementById('new_password'),document.getElementById('repassword')))
    {
        form.submit();
    }
}

function trimStr(str) { 
    return   str.replace(/(^\s*)|(\s*$)/g, ""); 
}

function CreateDiv(parent,content)
{
    var strFlag=parent.getAttribute("flag");
    if(strFlag && document.getElementById(strFlag))
    {
        return;
    }
    var div=document.createElement("span");
    div.innerHTML=content;
    div.style.color="#FF3300";
    var time=Date.parse(new Date());
    div.id="dv"+time;
    parent.setAttribute("flag","dv"+time);
    parent.appendChild(div);
}

function DisplayPersonInfo(obj)
{
    document.getElementById("dvpersoninfo").style.display="block";
    document.getElementById("dvuserlogin").style.display="none";
    if(obj)
    {	
        var avatar=obj.avatar?obj.avatar:"play_s.jpg";
        var sex=obj.sex?obj.sex:"play_s.jpg";
        var coins=obj.usercoins?obj.usercoins:0;
        var nickname=obj.nickname?obj.nickname:'';
        var usernum=obj.usernum?obj.usernum:0;
        var credit=obj.credit?obj.credit:0;
        var wealth=obj.wealth?obj.wealth:0;
        document.getElementById("imgpersonavatar").src=imageUrl+"/img/";
        document.getElementById("imgpersonsex").src=imageUrl+"/img/";
        document.getElementById("sppersoncoins").innerHTML=coins;
        document.getElementById("sppersonnickname").innerHTML=nickname;
        document.getElementById("sppersonusernum").innerHTML=usernum;
        document.getElementById("sppersoncredit").innerHTML=credit;
        document.getElementById("sppersonwealth").innerHTML=wealth;
    }
}

function changeIndexLiveType(type)
{
	var arr=[1,2,3,4];
	var len=arr.length;
        $("hdlivetype").value=type;
	for(var i=0;i<len;i++)
	{
		if(type==arr[i])
		{
			AddClassName($("liindexlivetypem"+arr[i]),"current");
			AddClassName($("ulindexlivetype"+arr[i]),"tab-box");
                        if ($("ulindexlivetype"+arr[i]).innerHTML == "") {
                            changePage($("hdcurrentpage"+type).value);
                        }
		}
		else
		{
			AddClassName($("liindexlivetypem"+arr[i]),"");
			AddClassName($("ulindexlivetype"+arr[i]),"tab-box hide");
		}
	}
	MakeIndexPage($("hdcurrentpage"+type).value,type);
}

function MakeIndexPage(page,type)
{
	var parentPage=$("dvindexpage");
				
	while(parentPage.getElementsByTagName("a").length>0)
	{
		arrChilds=parentPage.getElementsByTagName("a");
		var intPageLength=arrChilds.length;
		for(var i=0;i<intPageLength;i++)
		{
			if(arrChilds[i])
			{	
				ClearChildNodes(arrChilds[i]);
				
			}
		}
	}
	
	var totalPage=0;
	if(type==1)
	{
		totalPage=$("hdhotroompagecount").value;
	}
	else
	{
		totalPage=$("hdlivetotalcount").value;
	}
	var strPageContent="";
        if (page == 1) {
            strPageContent+= '<a href="javascript:changePage(1);">上一页</a>';
        } else {
            strPageContent+= '<a href="javascript:changePage('+(parseInt(page)-1)+');">上一页</a>';
        }
	for(var i=1;i<=totalPage;i++)
	{
		if(i==page)
		{
			strPageContent+= '<a href="javascript:changePage('+i+');" class="on">'+i+'</a>';
		}
		else
		{
			strPageContent+=  '<a href="javascript:changePage('+i+');" >'+i+'</a>';
		}
	}
        if (page == totalPage) {
            strPageContent+= '<a href="javascript:changePage('+totalPage+');">下一页</a>';
        } else {
            var p = parseInt(page)+1;
            strPageContent+= '<a href="javascript:changePage('+p+');">下一页</a>';
        }
	parentPage.innerHTML=strPageContent;
}

function changePage(page)
{
    if(page<1)
    {
        return;
    }
    
    var type=$("hdlivetype").value;
    
    /// 优化	by niugh
    jQuery.getJSON(
			"index_ajax.php?action=100002&page="+page+"&type="+type+"&randID="+Math.random(),
			function(objData){
				if(objData.confirm==1)
	            {
	                alert("亲，你的网络不给力，请重试！");
	            }
	            else if(objData.confirm==100)
	            { 
	                var length=objData.data.length;
	                var parentUserDv =document.getElementById("ulindexlivetype"+type);
					while(parentUserDv.getElementsByTagName("li").length>0)
					{
						arrChilds=parentUserDv.getElementsByTagName("li");
						var intBeforeLength=arrChilds.length;
						for(var i=0;i<intBeforeLength;i++)
						{
							if(arrChilds[i])
							{	
								ClearChildNodes(arrChilds[i]);
								
							}
						}
					}
					var strContent='';
	                for(var i=0;i<length;i++)
	                {
						var rid=0;
						if(type==1)
						{
							rid=objData.data[i]["rid"];
						}
						else
						{
							rid=objData.data[i]["rid"];
						}

	                        strContent+= '<li>';
	                        strContent+= '<a href="./'+rid+'" onmouseover="chooseRoomBlocNew(this,true);" onmouseout="chooseRoomBlocNew(this,false);" target="_blank"><img width="130" height="97" border="0" src="'+objData.data[i]["roomimg"]+'" onError="this.src=\'./application/uploads/liveroom/liveroomdefault.jpg\';">';
	                         if(objData.data[i]["openstatic"]==1){                        
	                         	strContent+= '<b class="liveing">直播中</b><b></b><b class="player"></b>';
	                         	if(type==1 && i<3 && page<2){
	                         		strContent+= '<span class="stars" style="background:url('+imageUrl+'/img/index/star_medal'+i+'.gif) no-repeat;"></span>';
	                         	}
	                        }else{
	                              strContent+= '<b class="live">无直播</b><b></b><b></b>';
	                              if(type==1 && i<3 && page<2){
	                         		strContent+= '<span class="stars" style="background:url('+imageUrl+'/img/index/star_medal'+i+'.gif) no-repeat;"></span>';
	                         	  }
	                        }
	                        strContent+= '</a>';
	                        strContent+= '<p class="shadows"></p>' ;
	                        strContent+= '<p class="online">'+MakeLiveLevelImgNew(objData.data[i]["credit"],1)+'<span class="fl name"> '+objData.data[i]["nickname"]+' </span></p>';
	                        strContent+= '<p class="c6"><span class="zhiye fl">'+objData.data[i]["job"]+'</span><span class="rshu fl"><em>'+objData.data[i]["roomcount"]+'</em>人</span></p>';   
	                        strContent+= '</li>'; 
	                }
						

	                parentUserDv.innerHTML=strContent;
	                document.getElementById("hdcurrentpage"+type).value=page;
	                MakeIndexPage(page,type);
	            }
			}
	);
}

function ClearChildNodes(obj)
{
    if(obj && obj.childNodes)
    {
       
		
		while(obj.childNodes>0)
		{
			var childs=obj.childNodes;
        	var length=childs.length;
			if(length>0)
        	{
			
				for(var i=0;i<length;i++)
				{
					
					if(childs[i])
					{
						if(childs[i].childNodes && childs[i].childNodes.length>0)
						{
							ClearChildNodes(childs[i])
						}
						else
						{
							childs[i].parentNode.removeChild(childs[i]);
							childs[i]=null;
						}
					}
					
				}
        	}
			len=null;
			childs=null;
		}

    }
    if(obj && obj.parentNode)
    {
        obj.parentNode.removeChild(obj);
    }
	obj=null;
}

function SearchLiveNum(ev)
{
	ev=ev||window.event;
    if (ev.keyCode==13) 
	{
		if($('txtsearch').value!='' && $('txtsearch').value!='搜索主播号')
		{
			OpenRoom($('txtsearch').value);
		}
	}
}
/*---js URLdecode--*/
function asc2str(str){
	return String.fromCharCode(str);
}

function str2asc(str){
	return str.charCodeAt(0).toString(16);
} 

function UrlEncode(str){
	var ret="";
	var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%";
	var tt= "";
	for(var i=0;i<str.length;i++){
		var chr = str.charAt(i);
		var c=str2asc(chr);
		tt += chr+":"+c+"n";
		if(parseInt("0x"+c) > 0x7f){
			ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
		}else{
			if(chr==" ")ret+="+";
			else if(strSpecial.indexOf(chr)!=-1)ret+="%"+c.toString(16);
			else ret+=chr;
		}
	}
	return ret;
}
 
function UrlDecode(str){
  var ret="";
  for(var i=0;i<str.length;i++){
   	var chr = str.charAt(i);
    if(chr == "+"){
      	ret+=" ";
    }else if(chr=="%"){
     	var asc = str.substring(i+1,i+3);
     	if(parseInt("0x"+asc)>0x7f){
      		ret+=asc2str(parseInt("0x"+asc+str.substring(i+4,i+6)));
      		i+=5;
     	}else{
      		ret+=asc2str(parseInt("0x"+asc));
      		i+=2;
     	}
    }else{
     	 ret+= chr;
    }
  }
  return ret;
}
/*---js URLdecode--*/
function PrintHead(type)
{
	var uid = getCookie('uid');
	var nickname=getCookie('nickname').replace(/\+/g," ");
	nickname = UrlDecode(nickname);
	var usernum=getCookie('usernum');
	var strContent="";
        strContent+='<div id="top-bar">';
        strContent+='<div class="ie6-out">';
        strContent+='<div class="ie6-in">';
	strContent+='<div class="w950">';
        strContent+='<div class="fl slogan"></div>';
        strContent+='<div class="fl search">';
        strContent+='<input type="text" value="搜索主播号" id="txtsearch"  class="field-text c9" onkeydown="SearchLiveNum(event);" onfocus="this.str=\'搜索主播号\';if(this.value==this.str){this.value=\'\'}" onblur="if(this.value==\'\'){this.value=\'搜索主播号\'}" />';
	strContent+='<input type="button" value="搜索" class="s-btn" onclick="if($(\'txtsearch\').value!=\'\' && $(\'txtsearch\').value!=\'搜索主播号\'){OpenRoom($(\'txtsearch\').value);}"  />';
	strContent+='</div>';
	if(uid>10000000)
	{
		strContent+='<div class="fr user"><a href="/recharge" target="_blank" class="fl recharge">充值</a><a href="user" class="fl" target="_blank" style="text-decoration:underline">'+nickname+'('+usernum+')</a><span class="fl">|</span><a href="./user" target="_blank" class="fl">个人中心</a><span class="fl">|</span><a onclick="logoff()" href="###" class="fl">退出</a></div>';
		strContent+='<div class="fr user hide"><a href="javascript:OpenLogin();">登录</a><a href="javascript:OpenRegister();">注册</a></div>';
	}
	else
	{
		strContent+='<div class="fr user"><a onclick="OpenLogin()" href="###" class="fl recharge">充值</a><a onclick="OpenLogin()" href="###">登录</a><a onclick="OpenRegister()" href="###">注册</a></div>';
		strContent+='<div class="fr user hide"></div>';
	}
	strContent+='</div>';
        strContent+='</div>';
	strContent+='</div>';
        strContent+='</div>';
	strContent+='<div id="header">';
        strContent+='<div class="ie6-out">';
        strContent+='<div class="ie6-in">';
	strContent+='<div class="w950">';
	strContent+='<div class="fl logo"><a href="/" title="返回首页">返回首页</a></div>';
	strContent+='<ul class="fl hd-menu">';
	if(type==1)
	{
		strContent+='<li><a href="/" id="m1" class="current" title="直播大厅">直播大厅</a></li>';
	}
	else
	{
		strContent+='<li><a href="/" id="m1" title="直播大厅">直播大厅</a></li>';
	}
	
	if(type==2)
	{
		strContent+='<li><a onclick="gotoUserCenter('+uid+');" href="###" id="m2" class="current" title="个人中心">个人中心</a></li>';
	}
	else
	{
		strContent+='<li><a onclick="gotoUserCenter('+uid+');" href="###" id="m2" title="个人中心">个人中心</a></li>';
	}
	
	if(type==3)
	{
		strContent+='<li><a href="###" onclick="gotoUserRecharge('+uid+');"  id="m3" class="current" title="充值中心">充值中心</a></li>';
	}
	else
	{
		strContent+='<li><a href="###"  onclick="gotoUserRecharge('+uid+');" id="m3" title="充值中心">充值中心</a></li>';
	}
	
	if(type==4)
	{
		strContent+='<li><a href="?action=1100001" class="current" id="m4" title="道具商城" target="_blank">道具商城</a></li>';
	}
	else
	{
		strContent+='<li><a href="?action=1100001" id="m4" title="道具商城" target="_blank">道具商城</a></li>';
	}
	
	if(type==5)
	{
		strContent+='<li><a href="top"  id="m5" class="current" title="排行榜">排行榜</a></li>';
	}
	else
	{
		strContent+='<li><a href="top" id="m5" title="排行榜">排行榜</a></li>';
	}

	strContent+='</ul>';
	strContent+='<a href="?action=600001&rid=1&uid='+uid+'" class="fr want">我要直播</a>';
	strContent+='</div>';
	strContent+='</div>';
        strContent+='</div>';
	strContent+='</div>';
	
    document.write(strContent);
	


}

function gotoUserCenter(uid)
{
	if(uid>10000000)
	{
            window.open("user");
            //location.href="user";
	}
	else
	{
		OpenLogin();
	}
	return;
}

function gotoUserRecharge(uid)
{
	if(uid>10000000)
	{
            window.open("recharge");
	}
	else
	{
		OpenLogin();
	}
}

function PrintFooter() {
    var strContent = "";
	strContent+='<div id="footer">';
	strContent+='<div class="w950">';
	strContent+='<p class="fl" style="width:40%;"><img src="'+imageUrl+'/img/index/foot_logo.png" alt="Ku123.com" class="fl" /><a href="?action=700004" target="_blank">关于Ku123</a>|<a href="?action=700004&r=2" target="_blank">隐私原则</a>|<a href="?action=700004&r=3" target="_blank">用户协议</a></p>';
	strContent+='<p class="fr" style="width:60%;">ICP证：沪ICP备09060246号-4   版权所有：上海我要网络发展有限公司&nbsp;&nbsp;&nbsp;联系电话：021-58815151 </p>';
	strContent+='</div>';
	strContent+='</div>';
    document.write(strContent);

    tongji();
}

function tongji() 
{
    var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
	
	//var cszz = document.createElement('script');

	//cszz.type = 'text/javascript';
	
	//cszz.async = true;
	
	//cszz.src = 'http://s22.cnzz.com/stat.php?id=4134928&web_id=4134928&show=pic1';
	
	//document.getElementsByTagName('body')[0].appendChild(cszz);

	var bd = document.createElement('script');
	
	bd.type = 'text/javascript';
	
	bd.async = true;
	
	bd.src = _bdhmProtocol + 'hm.baidu.com/h.js?01f48d69693e1a53097ec18f7d491e03';
	
	document.getElementsByTagName('body')[0].appendChild(bd);

}

function liveRegister()
{
	location.href="index.php?action=600001&rid=1&uid="+getCookie('uid');
}


function OpenRegister()
{
	return global_openRegister(2);
	var referrTag = getCookie("referrTag");
	
	if(typeof(timeAutoOpen)=='undefined')
	{
	}
	else if(timeAutoOpen)
	{
		clearTimeout(timeAutoOpen);
	}
	
	OpenLogin();
	
	if(referrTag.search(/YRT_/) == -1) {
		getLoginDv(2);
	}
}

function CheckAgreeLogin(obj)
{
	if(!obj.checked)
	{
		$("regbtn").disabled="disabled";
	}
	else
	{
		$("regbtn").disabled=false;
	}
}

function OpenLogin()
{
	return global_openRegister(1);
	var referrTag = getCookie("referrTag");
	
	if(typeof(timeAutoOpen)=='undefined')
	{
	}
	else if(timeAutoOpen)
	{
		clearTimeout(timeAutoOpen);
	}
	
	if(referrTag.search(/YRT_/) == -1) {
		var bgdiv=document.getElementById("loginMask");
		var iframe=document.getElementById("loginMaskBg");
		var loginBox=document.getElementById("loginBox");
		var regbox=$("registerBox");
		if(bgdiv && loginBox)
		{
			if(iframe)
			{
				iframe.style.display="block";
			}
			bgdiv.style.display="block";
			
		
				if(!regbox || regbox.style.display=="none")
				{
					loginBox.style.display="block";
				}

			
			
		}
		else
		{
			if(!iframe)
			{
				iframe=document.createElement("iframe");
				iframe.id="loginMaskBg";
				iframe.style.cssText="position: absolute; z-index: 550; width: 100%; height: 1721px; opacity: 0; left: 0px; top: 0px;filter : progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0,finishOpacity=100); ";
				document.body.appendChild(iframe);
			}
			else
			{
				iframe.style.display="block";
			}
			
			if(!bgdiv)
			{
				bgdiv=document.createElement("div");
				bgdiv.id="loginMask";
				bgdiv.style.cssText="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: black; opacity: 0.5; position: absolute; z-index: 555; left: 0px; top: 0px; height: 1721px; width: 100%;filter : progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50,finishOpacity=100); ";
				document.body.appendChild(bgdiv);
			}
			else
			{
				bgdiv.style.display="block";
			}
			
			if(!loginBox )
			{
				if( $("registerBox") && $("registerBox").style.display!="none")
				{
				
				}
				else
				{
					loginBox=document.createElement("div");
					loginBox.id="loginBox";
					var strContent="";
					
					
					strContent+='<div class="popUpBoxLogin">';
					strContent+='<div class="container">';
					strContent+='<div class="wrap">';
					strContent+='<ul class="tab-menu">';
					strContent+='<li id="t1" class="cur" onclick="getLoginDv(1);">登录</li>';
					strContent+='<li id="t2" onclick="getLoginDv(2);">快速注册</li>';
					strContent+='</ul>';
					strContent+='<div class="tab-box">';
					strContent+='<div id="login">';
					strContent+='<h2 class="slogan"><img src="'+imageUrl+'/img/s2.gif" alt="立即登录 与美女互动" title="立即登录 与美女互动"></h2>';
					strContent+='<div id="logerrormsg" class="cslogerror" style="line-height:normal;height:14px;"></div>';
					strContent+='<ul class="form">';
					strContent+='<li class="divLoginMail">';
					strContent+='<label class="fl">邮箱</label>';
					strContent+='<input id="loginusername" type="text" value="请输入邮箱" class="fl ibs" onfocus="if(this.value==\'请输入邮箱\'){this.value=\'\';}AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');" maxlength="40" onblur="if(this.value==\'\'){this.value=\'请输入邮箱\';} AddClassName(this,\'fl ibs\');setTextColor(this,\'#999999\');">';
					strContent+='<a id="close_input_div_login" class="clearMessage" style="display: none; top: 6px; right: 10px; z-index: 10001;" href="###"></a>';
					strContent+='</li>';
					strContent+='<li>';
					strContent+='<label class="fl">密码</label>';
					strContent+='<input id="loginpassword" type="password" class="fl ibs" maxlength="12" onkeyup="KeyUpLogin(event)" onfocus="AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');" onblur="AddClassName(this,\'fl ibs\');setTextColor(this,\'#999999\');">';
					strContent+='</li>';
										strContent+='<li style="height:30px; display:none;" id="logincode">';
                                        strContent+='<label class="fl f14 c9">验证码</label>';
                                        strContent+='<input type="text" name="loginsessimg" id="loginsessimg" tabindex="4" maxlength="4" class="fl ibs" style="width:50px;" value="" onblur="if(this.value.length != 4){AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');}" />&nbsp;';
                                        strContent+='<img id="login_img_authcode" onclick="this.src=this.src+\'&rand=\'+new Date().getTime()" src="./application/libraries/sessimg.php?type=login">';
                                        strContent+='</li>';
					strContent+='<li class="agree">';
					strContent+='<input id="cbsavepassword" type="checkbox" checked="checked" class="fl chk"><span class="fl mar">记住我</span><a href="?action=200003" target="_blank" class="fl mar">忘记密码</a><button type="button" onclick="LoginFormSumbit($(\'loginusername\'),$(\'loginpassword\'));" class="fr login">登录</button>';
					strContent+='</li>';
					strContent+='<li class="Q_login"><a href="javascript:toQzoneLogin();"><img src="'+imageUrl+'/img/Q_login.png" onmouseover="this.src=\''+imageUrl+'/img/Q_login_hover.png\'" onmouseout="this.src=\''+imageUrl+'/img/Q_login.png\'" alt=""></a></li>';
					strContent+='</ul>';
					strContent+='</div>';
					strContent+='<div id="reg" class="hide">';
					strContent+='<h2 class="slogan"><img src="'+imageUrl+'/img/s1.gif" alt="3秒快速注册 立即与美女互动" title="3秒快速注册 立即与美女互动"></h2>';
					strContent+='<ul class="form">';
					strContent+='<li class="divregMail" style="position:relative;">';
					strContent+='<label class="fl">邮箱</label>';
					strContent+='<input id="regemail" type="text" class="fl ibs" maxlength="40" value="请使用您常用的邮箱"  onfocus="if(this.value==\'请使用您常用的邮箱\'){this.value=\'\';}AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');" onblur="if(this.value==\'\'){this.value=\'请使用您常用的邮箱\';$(\'spregemailok\').style.display=\'none\';$(\'spregemailerror\').style.display=\'none\';} if(initInput == 0) {AuthUserName(this,\'reg\');}AddClassName(this,\'fl ibs\');setTextColor(this,\'#999999\');">';
					strContent+='<span id="spregemailerror" style="display:none;" class="error">邮箱格式有误，请重新输入</span>';
					strContent+='<span id="spregemailok" style="display:none;" class="ok"></span>';
					strContent+='<a id="close_input_register" class="clearMessage" style="display: none; top: 6px; right: 10px; z-index: 10001;" href="###"></a>';
					strContent+='</li>';
					strContent+='<li style="position:relative;">';
					strContent+='<label class="fl">密码</label>';
					strContent+='<input id="regpassword" type="password" maxlength="12"  class="fl ibs" onfocus="AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');" onblur="if(trimStr(this.value).length>0){PasswordBlur(this,\'reg\')}else{$(\'spregpassworderror\').style.display=\'none\';$(\'spregpasswordok\').style.display=\'none\';};AddClassName(this,\'fl ibs\');setTextColor(this,\'#999999\');" />';
					strContent+='<span id="spregpasswordok" style="display:none;" class="ok"><img src="'+imageUrl+'/img/login_ok.gif" alt=""></span>';
					strContent+='<span id="spregpassworderror" style="display:none;" class="error"><img src="'+imageUrl+'/img/error.gif" alt="">密码格式有误，请重新输入</span>';
					strContent+='</li>';
					strContent+='<li style="position:relative;">';
					strContent+='<label class="fl">确认密码</label>';
					strContent+='<input id="regrepassword" type="password" maxlength="12" onkeyup="KeyUpRegister(event)" class="fl ibs"   onfocus="AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');" onblur="if(trimStr($(\'regpassword\').value).length<1 && trimStr($(\'regrepassword\').value).length<1){$(\'sprepasswordok\').style.display=\'none\';$(\'sprepassworderror\').style.display=\'none\';}else{confirmPasswordBlur($(\'regpassword\'),$(\'regrepassword\'));};AddClassName(this,\'fl ibs\');setTextColor(this,\'#999999\');">';
					strContent+='<span id="sprepasswordok" style="display:none;" class="ok"><img src="'+imageUrl+'/img/login_ok.gif" alt=""></span>';
					strContent+='<span id="sprepassworderror" style="display:none;" class="error"><img src="'+imageUrl+'/img/error.gif" alt="">两次输入的密码不一致</span>';
					strContent+='</li>';
                                        strContent+='<li style="height:30px;visibility:hidden;" id="recode">';
                                        strContent+='<label class="fl f14 c9">验证码</label>';
                                        strContent+='<input type="text" name="sessimg" id="sessimg" onkeyup="KeyUpRegister(event)" maxlength="4" class="fl ibs" style="width:50px;" value="" onblur="if(this.value.length == 4){AddClassName(this,\'fl ibs\');setTextColor(this,\'#999999\');}else{AddClassName(this,\'fl ibs ibs-focus\');setTextColor(this,\'#333333\');}" />&nbsp;';
                                        strContent+='<img id="imgauthcode" onclick="this.src=this.src+\'&rand=\'+new Date().getTime()" src="./application/libraries/sessimg.php?type=register">';
                                        strContent+='</li>';
					strContent+='<li class="agree">';
					strContent+='<input type="checkbox" id="login-agree" checked="checked" class="fl chk"><span class="fl mar">我同意《 <a href="?action=700004&r=3" target="_blank">Ku123协议</a> 》</span><a href="javascript:RegisterFormSumbit($(\'regemail\'),$(\'regpassword\'));" class="fr reg">注册</a>';
					strContent+='</li>';
					strContent+='<li class="Q_login"><a href="javascript:toQzoneLogin();"><img src="'+imageUrl+'/img/Q_login.png" onmouseover="this.src=\''+imageUrl+'/img/Q_login_hover.png\'" onmouseout="this.src=\''+imageUrl+'/img/Q_login.png\'" alt=""></a></li>';
					strContent+='</ul>';
					strContent+='</div>';
					strContent+='</div>';
					strContent+='</div>';
					strContent+='</div>';
					strContent+='<a href="###" class="close" onclick="CloseLogin();">关闭</a>';
					strContent+='</div>';
					
					loginBox.innerHTML=strContent;
					document.body.appendChild(loginBox);

					var error_num = getCookie('len');
			
					if (error_num > 2 )
					{
						document.getElementById("logincode").style.display = "block";
						
					}
				}
				
			} 
			
		}
		getLoginDv(1);
	}
	else {
		var loginBox=document.getElementById("loginBox");
		
		if(loginBox != null) {
			loginBox.style.display="block";
		}
		else {
			loginBox=document.createElement("div");
			loginBox.id="loginBox";
			var strContent="";
			
			strContent += '<div class="q-bg" id="bgId"></div>';
			strContent += '<div class="popUpBox w636">';
			strContent += '<a href="###" class="indexClose" onclick="CloseLogin();">关闭</a>';
			strContent += '<div class="popUpBoxInside">';
			strContent += '<div class="wrap">';
			strContent += '<ul class="tab-menu">';
			strContent += '<li id="t3" class="cur">快速登录</li>';
			strContent += '</ul>';
			strContent += '<div class="tab-box">';
			strContent += '<div id="login">';
			strContent += '<h2 class="fl slogan"><img src="'+imageUrl+'/img/s4.png" alt="一键注册，与美女零距离沟通" /></h2>';
			strContent += '<p class="Q_big_login"><a href="javascript:toQzoneLogin();"><img src="'+imageUrl+'/img/Q_big_login.png" alt="QQ登录" /></a></p>';
			strContent += '<p class="Q_agree">默认同意《 <a href="?action=700004&r=3" target="_blank" class="f69">ku123协议</a>》</p>';
			strContent += '</div>';
			strContent += '</div>';
			strContent += '</div>';
			strContent += '</div>';
			strContent += '</div>';
			strContent += '<script type="text/javascript">document.getElementById("bgId").height = document.body.height;</script>';
			loginBox.innerHTML=strContent;
			document.body.appendChild(loginBox);
		}
	}
}

var loginSuggest=null;
var regSuggest=null;
function getLoginDv(index)
{
	if(index==1)
	{
		AddClassName($("t1"),"cur");
		AddClassName($("t2"),"");
		$("login").style.display="block";
		$("reg").style.display="none";
		
		if(!loginSuggest) {
			loginSuggest = jQuery("#loginusername").autoMail("div_login");
		}
		
	}
	else
	{
		AddClassName($("t1"),"");
		AddClassName($("t2"),"cur");
		$("reg").style.display="block";
		$("login").style.display="none";
		
		if(!regSuggest) {
			regSuggest = jQuery("#regemail").autoMail("register");
		}
		
	}
}

function EmailBlur(obj,id)
{

	if(CheckEmailNew(obj))
	{
		
		if(obj.value.length>0 && obj.value!="请使用您常用的邮箱")
		{
			$("sp"+id+"emailok").style.display="";
			$("sp"+id+"emailerror").style.display="none";
			return true;
		}
	}
	else
	{
		$("sp"+id+"emailerror").innerHTML='邮箱格式错误,请重新输入';
		$("sp"+id+"emailerror").style.display="";
		$("sp"+id+"emailok").style.display="none";
		return false;
	}
}

function AuthUserName(obj,id)
{
	
	if(EmailBlur(obj,id))
	{
		checkUserName(obj,id);
	}
}

function setTextColor(obj,color)
{
	if(obj)
	{
		obj.style.color=color;
	}
}


function printLeftSpan()
{
    var strContent="";
    strContent+='<div class="col1">';
		
    strContent+='<div class="indexlefttopicon">';
    strContent+='<div class="roundlefttop"></div>';
    strContent+='<div class="roundtopmiddle"></div>';
    strContent+='<div class="roundrighttop"></div>';
    strContent+='</div>';
    strContent+='<div class="indexlefttop1">';
    strContent+='<dl>';
        
    strContent+='<dt class="liveHall">';
    strContent+='<a href="###" rela="all"></a>';
    strContent+='</dt>';
        
    strContent+='</dl>';
    strContent+='<div class="kuainan">';
    strContent+='<dl>';
        
    strContent+='<dt onclick="displayChildMenu(this)">';
    strContent+='<span class="onbigfont"><span style="float:left;display:inline-block;">快男超女';
    strContent+='</span>';
    strContent+='<img alt="" class="indexleftstaricon" src="'+imageUrl+'/img/frame_down.gif">';
    strContent+='</span>';
    strContent+='</dt>';
        
    strContent+='<dd>';
        
    strContent+='<a href="###" style="background-image:url('+imageUrl+'/img/indexleftiocnmiddle.png);color:#fff;font-weight:bold;" rela="r4">巨星</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" rela="r1">明星</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" rela="r2">红人</a>';
    strContent+='<a style="height:1px;background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" rela="r3">新秀</a>';
    strContent+='<a style="height:1px;background-color:#cccccc;"></a>';
        
    strContent+='</dd>';
        
    strContent+='</dl>';

    strContent+='<dl>';
        
    strContent+='<dt onclick="displayChildMenu(this)">';
    strContent+='<span class="onbigfont" href="###"><span style="float:left;display:inline-block;">综艺舞台</span>';
    strContent+='<img alt="" class="indexleftstaricon" src="'+imageUrl+'/img/frame_down.gif"></span>';
    strContent+='</dt>';
        
    strContent+='<dd>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" rela="u2">MC</a>';   
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
    strContent+='<a href="?action=200008&s=left" target="_blank" rela="u3">聊吧</a>';       
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
    strContent+='<a href="?action=200008&s=left" target="_blank" rela="fu1">舞区</a>';        
    strContent+='</dd>';
        
    strContent+='</dl>';
    strContent+='</div>';
    strContent+='</div>';
    strContent+=' <div style="height:14px;"><div class="roundleftbottom"></div><div class="roundbottommiddle"></div><div class="roundrightbottom"></div></div>';
    
    strContent+='<div class="indexlefttopicon">';
    strContent+='<div class="roundlefttop"></div>';
    strContent+='<div class="roundtopmiddle"></div>';
    strContent+='<div class="roundrighttop"></div>';
    strContent+='</div>';
    strContent+='<div class="indexlefttop1">';
    strContent+='<dl>';
        
    strContent+='<dt onclick="displayChildMenu(this)">';
    strContent+='<span class="onbigfont">';
    strContent+='<span style="width:120px;display:inline-block;float:left;">热门游戏</span>';
    strContent+='<img alt="" class="indexleftstaricon" src="'+imageUrl+'/img/frame_down.gif"></span>';
    strContent+='</dt>';
        
    strContent+='</dl>';
    strContent+='<div class="kuainan">';
    strContent+='<dl>';
               
    strContent+='<dd>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" style="background-image:url('+imageUrl+'/img/indexleftiocnmiddle.png);color:#fff;font-weight:bold;">敬请期待</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" >敬请期待</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=200008&s=left" target="_blank" >敬请期待</a>';
    strContent+='<a style="height:1px;background-color:#cccccc;"></a>';
		
    strContent+='<a href="?action=200008&s=left" target="_blank">敬请期待</a>';
    strContent+='<a style="height:1px;background-color:#cccccc;"></a>';
		
    strContent+='</dd>';
        
    strContent+='</dl>';
    strContent+='</div>';
    strContent+='</div>';
    strContent+=' <div style="height:14px;"><div class="roundleftbottom"></div><div class="roundbottommiddle"></div><div class="roundrightbottom"></div></div>';

    strContent+='<div class="indexlefttopicon">';
    strContent+='<div class="roundlefttop"></div>';
    strContent+='<div class="roundtopmiddle"></div>';
    strContent+='<div class="roundrighttop"></div>';
    strContent+='</div>';
    strContent+='<div class="indexlefttop1">';
    strContent+='<dl>';
        
    strContent+='<dt onclick="displayChildMenu(this)"><span class="onbigfont"><span style="width:120px;display:inline-block;height:32px;line-height:32px;float:left;">热门活动</span>';
    strContent+='<a class="indexleftstaricon" style="font-size:12px;color:#653566;font-weight:normal;text-decoration:underline;margin-top:0;" href="?action=700003" title="更多活动" target="_blank">更多活动</a>';
    strContent+='</span>';
    strContent+='</dt>';
        
    strContent+='</dl>';
    strContent+='<div class="kuainan">';
    strContent+='<dl>';
               
    strContent+='<dd>';
        
    strContent+='<a href="?action=700005&id=5" style="background-image:url('+imageUrl+'/img/indexleftiocnmiddle.png);color:#fff;font-weight:bold;" >抢星有礼</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
    
    strContent+='<a href="?action=700005&id=1">充值大酬宾</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=700005&id=2">爱的薰衣草</a>';
    strContent+='<a style="height:1px; background-color:#cccccc;"></a>';
        
    strContent+='<a href="?action=700005&id=3">勤劳的小主播</a>';
    strContent+='<a style="height:1px;background-color:#cccccc;"></a>';
        
    strContent+='</dd>';
        
    strContent+='</dl>';
    strContent+='</div>';
    strContent+='</div>';
    strContent+=' <div style="height:14px;"><div class="roundleftbottom"></div><div class="roundbottommiddle"></div><div class="roundrightbottom"></div></div>';  
    
    strContent+='</div>';
    document.write(strContent);
}

function OpenRoom(rid)
{
    window.open(rid);

}

function KeyUpLogin(ev) 
{
	ev=ev||window.event;
	if (ev.keyCode==13) 
	{
		LoginFormSumbit(document.getElementById('loginusername'),document.getElementById('loginpassword'));
	}
}

function KeyUpRegister(ev)
{
	ev=ev||window.event;
	if (ev.keyCode==13 ) 
	{
		RegisterFormSumbit($('regemail'),$('regpassword'));
	}
}


function logoff()
{
	
	/// 优化  by niugh
	jQuery.getJSON(
			"index_ajax.php?action=100003&randID="+Math.random(),
			function(objData){
				if(objData.confirm==100)
		        {
		            //CloseLogin();
		            //DisplayPersonInfo(objData.data);
		            location.href=location.href.replace(/#+/,"");
		        }
			}
	);
}

function MakeLiveLevelImg(credit,type)
{
	 var livelevel=GetLevelByCredit(credit,arrLiveLevel);
	 if(!livelevel)
         {
             livelevel=1;
         }
	var x=arrLiveLevel[livelevel].x;
	var y=arrLiveLevel[livelevel].y;
	var strDiffPosition=(-x)+"px "+(-y)+"px"
	var str='<span style="background-position:'+strDiffPosition+';" class="liveleveldifiocn">&nbsp;</span>';
	if(type==1)
	{
		return str;
	}
	else
	{
		document.write(str);
	}
}
function MakeLiveLevelImgNew(credit,type)
{
	var livelevel=GetLevelByCredit(credit,arrLiveLevel);
	 if(!livelevel)
         {
             livelevel=1;
         }
	
	var x=arrLiveLevel[livelevel].x;
	var y=arrLiveLevel[livelevel].y;
	var strDiffPosition=(-x)+"px "+(-y)+"px"
	var str='<span class="fl level" style="background:url(http://static.ku123.com/img/wealthlevelicon.gif?20120804) no-repeat '+strDiffPosition+';">&nbsp;</span>';
	if(type==1)
	{
		return str;
	}
	else
	{
		document.write(str);
	}
}
function init()
{
    var roomcredit=$("sppersoncredit").value;
    if(!roomcredit)
    {
        roomcredit=0;
    }
    var livelevel=GetLevelByCredit(roomcredit,arrLiveLevel);
    if(!livelevel)
    {
        livelevel=1;
    }
    //	$("splivelevel").innerHTML=livelevel;
    var nextCredit=GetNextLevelCredit(livelevel,arrLiveLevel);
    var width=0
    if(nextCredit==arrLiveLevel[livelevel]["credit"])
    {
        width=100;
    }
    else
    {
        width=Math.round((roomcredit-arrLiveLevel[livelevel]["credit"])*100/(GetNextLevelCredit(livelevel,arrLiveLevel)-arrLiveLevel[livelevel]["credit"]));
    }
	
    $("splivelevelrate").style.width=width+"%";
	$("spparlivelevelrate").title="距离下一级还差"+(nextCredit-roomcredit)+"贝壳";
	
	var objDifLevel=$("splivediflevelicon");
	var x=arrLiveLevel[livelevel].x;
	var y=arrLiveLevel[livelevel].y;
	objDifLevel.style.backgroundPosition=(-x)+"px "+(-y)+"px";
	objDifLevel.style.backgroundImage="url("+imageUrl+"/img/wealthlevelicon.gif?20120804)";     
  
    roomcredit=$("sppersonwealth").value;
    if(!roomcredit)
    {
        roomcredit=0;
    }
    livelevel=GetLevelByCredit(roomcredit,arrWealthLevel);
    if(!livelevel)
    {
        livelevel=1;
    }
    //	$("splivelevel").innerHTML=livelevel;
    nextCredit=GetNextLevelCredit(livelevel,arrWealthLevel);
    if(nextCredit==arrLiveLevel[livelevel]["credit"])
    {
        width=100;
    }
    else
    {
        width=Math.round((roomcredit-arrWealthLevel[livelevel]["credit"])*100/(nextCredit-arrWealthLevel[livelevel]["credit"]));
    }
	
    $("splivewealthrate").style.width=width+"%";
	$("spparlivewealthrate").title="距离下一级还差"+(nextCredit-roomcredit)+"贝壳";
	
	x=arrWealthLevel[livelevel].x;
	y=arrWealthLevel[livelevel].y;
	$("spwealthleveliocn").style.backgroundPosition=(-x)+"px "+(-y)+"px";
	

}

function MainLoginUp(ev) 
	{
        ev=ev||window.event;
        if (ev.keyCode==13) 
		{
			if($("loginMask") && $("loginMask").style.display!="none")
			{
			
			}
			else
			{
				 LoginFormSumbit(document.getElementById('txtusername'),document.getElementById('txtpassword'),1);
			}
        }
    }

function addEvent(el,eventType,fn){
    if(el.addEventListener){
        el.addEventListener(eventType,fn,false);
    }else if(el.attachEvent){
        el.attachEvent("on" + eventType,fn);
    }else{
        el["on"+eventType]=fn;
    }
}    


function interTimeBanner(max)
{
	var intertime=setInterval(function(){
				ChangeAdv(index,max);
				index++;
				if(index>=max)
				{
					index=0;
				}
									   	},3000);
}

function checkUserName(obj,id)
{
	
	jQuery.getJSON(
			"index_ajax.php?action=200004&username="+trimStr(obj.value)+"&randID="+Math.random(),
			function(objData){
				if(objData.confirm==1)
	            {
	                $("sp"+id+"emailerror").innerHTML='邮箱已被注册，建议:<a href="javascript:toQzoneLogin();">使用QQ登录</a>';
					$("sp"+id+"emailerror").style.display='';
					$("sp"+id+"emailok").style.display='none';
	            }
	            else if(objData.confirm==100)
	            {
					  $("sp"+id+"emailerror").style.display='none';
					  $("sp"+id+"emailok").style.display='';
				}
			}
	);
}

function printShare(title, url)
{
    if (typeof(url) == "undefined" || url == "" || url == "null") 
	{
        url = location.href;
    }
	
    var str='<a class="fl s1" href="http://share.renren.com/share/buttonshare.do?link='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'" title="分享到人人网" target="_blank"></a>'+
    '<a class="fl s2" href="http://v.t.sina.com.cn/share/share.php?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'" title="分享到新浪微博" target="_blank"></a>'+
    '<a class="fl s3" href="http://www.kaixin001.com/repaste/share.php?rurl='+encodeURIComponent(url)+'&rtitle='+encodeURIComponent(title)+'" title="分享到开心网" target="_blank"></a>'+
    '<a class="fl s4" href="http://cang.baidu.com/do/add?it='+encodeURIComponent(title)+'&iu='+encodeURIComponent(url)+'" title="收藏到百度搜藏" target="_blank"></a>'+
    '<a class="fl s5" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(url)+'" title="分享到QQ空间" target="_blank"></a>'+
    '<a class="fl s6" href="http://v.t.qq.com/share/share.php?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'" title="分享到腾讯微博" target="_blank"></a>'+
    '<a class="fl s7" href="http://www.douban.com/recommend/?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'" title="分享到豆瓣" target="_blank"></a>';
    document.write(str);
}

/*获取Cookie值*/
function getCookie(c_name)
{
    if(document.cookie.length>0){
        c_start=document.cookie.indexOf(c_name + "=")
        if(c_start!=-1){ 
            c_start=c_start + c_name.length+1 
            c_end=document.cookie.indexOf(";",c_start)
            if(c_end==-1) c_end=document.cookie.length
            return decodeURI(document.cookie.substring(c_start,c_end))
        }
    }
    return "";
}
/*清除cookie值*/
function delCookie(name)
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = getCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
/*增加Cookie值*/
function setCookie(name,value,expire)   //expire过期时间(ms)
{
    var exp  = new Date();
    exp.setTime(exp.getTime() + expire);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}


function GetChatLength(str)
{
	str=str.replace(/\[#(.+?)#\]/gi,'#');
	var arr=str.split("");
	return arr.length;
}

var isIEmac = false; /*@cc_on @if(@_jscript&&!(@_win32||@_win16)&&
(@_jscript_version<5.5)) isIEmac=true; @end @*/
var isMSIE = (-[1,]) ? false : true;


function hotKeys() 
{
	var ua = navigator.userAgent.toLowerCase();
	var str = '';
	var isWebkit = (ua.indexOf('webkit') != - 1);
	var isMac = (ua.indexOf('mac') != - 1);
	
	if (ua.indexOf('konqueror') != - 1) 
	{
		str = 'CTRL + B'; // Konqueror
	} 
	else if (window.home || isWebkit || isIEmac || isMac) 
	{
		str = (isMac ? 'Command/Cmd' : 'CTRL') + ' + D'; // Netscape, Safari, iCab, IE5/Mac
	}
	return ((str) ? 'Press ' + str + ' to bookmark this page.' : str);
}

function isIE8() 
{
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') 
	{
		var ua = navigator.userAgent;
		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null) 
		{
			rv = parseFloat(RegExp.$1);
		}
	}
	if (rv > - 1) 
	{
	if (rv >= 8.0) 
	{
		return true;
	}
	}
	return false;
}

function addBookmark(cjTitle,cjHref) 
{
	
	
			if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) 
			{
				
				window.sidebar.addPanel(cjTitle, cjHref, ""); // Gecko
				return ;
			} 
			else if (isMSIE && typeof window.external == "object") 
			{
				
				if (isIE8()) 
				{
					window.external.AddToFavoritesBar(cjHref, cjTitle); // IE 8
				} else 
				{
					window.external.AddFavorite(cjHref, cjTitle); // IE <=7
				}
				return ;
		
			}
			else if (window.opera) {
                    
                    return;
                } 
				else {
                    alert(hotKeys());
				}
	
	
}


function GetCurrentUnixTime()
{
	return Math.round(new Date().getTime()/1000);
}

var isIe6=0;
function AddClassName(obj,name)
{
	if(obj)
	{
		if(obj.className)
		{
			obj.className=name;
		}
		else
		{
			obj.setAttribute("class",name);
			obj.setAttribute("className",name);
			
		}
	}
}

function GetClassName(obj)
{
	var name="";
	if(obj)
	{
		if(obj.className)
		{
			name=obj.className;
		}
		else
		{
			if(isIe6>0)
			{
				name=obj.getAttribute("className",name);
			}
			else
			{
				if(window.XMLHttpRequest)
				{
					name=obj.getAttribute("class",name)
				}
				else
				{
					isIe6=1;
					name=obj.getAttribute("className",name);
				}
			}
		}
	}
	return name;
}


var childWindow;
function toQzoneLogin()
{
	childWindow = window.open("./qq_login.php","TencentLogin","width=450,height=320,menubar=0,scrollbars=1, resizable=1,status=1,titlebar=0,toolbar=0,location=1");
} 

function closeChildWindow()
{
	childWindow.close();
}

function AlertDiv(str)
{
	if($("dvalertdv"))
	{
		$("dvalertdv").style.display="block";
	}
	else
	{
		var alertDv=document.createElement("div");
		alertDv.id="dvalertdv";
	
			var strContent="";
		 strContent+='<div class="popUpBoxAlert hide" style="display:block;">';
		 strContent+='<div class="container">';
		 strContent+='<a href="###" class="close" title="关闭" onclick="$(\'dvalertdv\').style.display=\'none\';">&times;</a>';
		 strContent+='<p id="palertstrp" class="f14"></p>';
		 strContent+='<p style="padding-top:20px;"><img style="cursor:pointer;" src="'+imageUrl+'/img/pub/sure.gif" alt = "" onclick="$(\'dvalertdv\').style.display=\'none\';" /></p>';
		 strContent+='</div>';
		 strContent+='</div>';
		 alertDv.innerHTML=strContent;
		 document.body.appendChild(alertDv);
	}
	$("palertstrp").innerHTML=str;
			
}


function top2MouseHove(id)
{
	AddClassName($(id),"hover");
}

function top2MouseOut(id)
{
	AddClassName($(id),"hover hide");
}

function win_open(title, body) {
    if (title == '') {
        title = '提示';
    }
    var html = '<div id="maskBg" class="maskBg"></div><div id="maskPay" class="maskPay hide">'+
    '<div class="tit f14 ce69"><strong class="fl">'+title+'</strong><a href="###" class="fr close" title="关闭" onclick="close_win();">关闭</a></div>'+
    '<div class="container" id="mask_con">';
    html += body;
    html += '</div></div>';
    var obj=$('popPay');

    if(obj)
    {
        obj.innerHTML = html;
    }
    else
    {
        obj=document.createElement("div");
        obj.id="popPay";
        obj.innerHTML=html;
        document.body.appendChild(obj);
    }
    obj.style.display = 'block';
    $("maskPay").style.display = 'block';
    $('maskBg').style.display='block';
    $('maskBg').style.height = document.body.offsetHeight;
}
function close_win() {
    if ($("maskPay")) {
        $("maskPay").style.display = 'none';
    }
    if ($('maskBg')) {
        $('maskBg').style.display='none';
    }
    if ($("popPay")) {
        $("popPay").style.display = 'none';
    }
}




function WealthCreateStr(wealth,uid,starlevel)
{
    if(!starlevel)
    {
        starlevel = 0;
    }
	if(!wealth)
    {
        wealth=0;
    }
	var wealthLevel=0;
	if(wealth>0)
	{
		 wealthLevel=GetLevelByCredit(wealth,arrWealthLevel);
	}
	
	var strContent="";
	
	if(wealthLevel>0)
	{
		var x=arrWealthLevel[wealthLevel].x*(-1);
		var y=arrWealthLevel[wealthLevel].y*(-1);
		strContent+="<span style='background-image:url("+imageUrl+"/img/wealthlevelicon.gif?20120804);display:inline-block;width:50px;height:20px;line-height:20px;background-position:"+x+"px "+y+"px;'>";
                                            if(starlevel>0)
                                            {
                                                strContent+="<em class=\"wealthlevelstar"+starlevel+"\">&nbsp;</em></span>";
                                            }
                                            else{
                                                strContent+="&nbsp;</span>";
                                            }    
                      }
	return strContent;
}

function LiveLevelCreateStr(credit,uid)
{
	
	
	if(!credit)
	{
		credit=0;
	}
	var livelevel=GetLevelByCredit(credit,arrLiveLevel);
	if(!livelevel)
	{
		livelevel=1;
	}
	var strContent="";
	
	var x=arrLiveLevel[livelevel].x;
	var y=arrLiveLevel[livelevel].y;
	var strPosition1=(-x)+"px "+(-y)+"px";

	strContent+='<span class="liveleveldifiocn" style="background-image: url('+imageUrl+'/img/wealthlevelicon.gif?20120804); background-position:'+strPosition1+'; ">&nbsp;</span>'
	return strContent;

}




function getElementPos(el) {
 
    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') != -1);
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
 
 
    if(el.parentNode === null || el.style.display == 'none')
    {
        return false;
    }
 
    var parent = null;
    var pos = [];
    var box;
 
    if(el.getBoundingClientRect)    //IE
    {
        box = el.getBoundingClientRect();
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
 
        return {x:box.left + scrollLeft, y:box.top + scrollTop};
    }
    else if(document.getBoxObjectFor)   // gecko
    {
        box = document.getBoxObjectFor(el);
 
        var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
        var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;
 
        pos = [box.x - borderLeft, box.y - borderTop];
    }
    else    // safari & opera
    {
        pos = [el.offsetLeft, el.offsetTop];
        parent = el.offsetParent;
        if (parent != el) {
            while (parent) {
                pos[0] += parent.offsetLeft;
                pos[1] += parent.offsetTop;
                parent = parent.offsetParent;
            }
        }
        if (ua.indexOf('opera') != -1
            || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' ))
        {
                pos[0] -= document.body.offsetLeft;
                pos[1] -= document.body.offsetTop;
        }
    }
 
    if (el.parentNode) {parent = el.parentNode;}
    else {parent = null;}
 
    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')
    { // account for any scrolled ancestors
        pos[0] -= parent.scrollLeft;
        pos[1] -= parent.scrollTop;
 
        if (parent.parentNode) {parent = parent.parentNode;}
        else {parent = null;}
    }
    return {x:pos[0], y:pos[1]};
}

function chooseRoomBloc(obj) {
    var lis = obj.parentNode.getElementsByTagName("li");
    if (lis) {
        for (var i = 0; i < lis.length; i++) {
            AddClassName(lis[i], "");
        }
        AddClassName(obj, "hover");
    }   
}
function chooseRoomBlocNew(obj,state) {
           var blist=obj.getElementsByTagName("b");
           if(blist){
                if(state==true){
                       AddClassName(blist[1], "bg"); 
                }else{
                     AddClassName(blist[1], ""); 
                }
           }
}
var vipTimeout = 0;
function showVip() {
    $('vip_bloc').style.display='block';
}


function hideVip() {
    vipTimeout=setTimeout(function()
    {
        $("vip_bloc").style.display = "none";
    },500);
}

function hideVipBloc() {
    $("vip_bloc").style.display = "none";
}
function showVipBloc() {
    clearTimeout(vipTimeout);
    $("vip_bloc").style.display = "block";
}

function getDate(time) {
    var date = new Date(time * 1000);
    h = date.getHours();
    i = date.getMinutes();
    s = date.getSeconds();
    day = date.getDate();
    mon = date.getMonth()+1;
    year = date.getFullYear();
    if (s < 10) {
        s = "0"+s;
    }
    if (i < 10) {
        i = "0"+i;
    }
    if (h < 10) {
        h = "0"+h;
    }
    if (day < 10) {
        day = "0"+day;
    }
    if (mon < 10) {
        mon = "0"+mon;
    }
    return year+'-'+mon+'-'+day+' '+h+':'+i+":"+s;
}

addEvent(window,"load",function(ev){
    if ($('vip_bloc') && $("is_expire")) {
        $('vip_bloc').style.display='block';
    }
	var obj=$("t_tongji");
	
	if(obj != null) {
		while(obj.nextSibling)
	    {
	    	obj=obj.nextSibling;
	    	if(obj.title &&  obj.title=="站长统计")
	    	{
	    		obj.style.display="none";
	    		break;	
	    	}
		}
	}
}) ;



//var arrTaskBottom=[159,127,102,78,60,39,30];
var arrTaskBottom=[0,0,0,0,0,0,0];
function displayTaskInfo(target,award,id)
{
    var obj=$("dvtaskitem");
    if(obj)
    {
        AddClassName(obj,"task-item");
        $("ptasktarget").innerHTML=target;
        $("ptaskaward").innerHTML=award;
    }
    else
    {
        obj=document.createElement("div");
        obj.id="dvtaskitem";
        AddClassName(obj,"task-item");
        var strContent="";
        strContent+='<h3>任务目标</h3>';
        strContent+='<p id="ptasktarget" class="c6">'+target+"</p>";
        strContent+='<p id="ptasksendhonghua" style="padding:0 0 0 7px;"></p>';
        strContent+='<h3>任务奖励</h3>';
        strContent+='<p id="ptaskaward" class="c3">'+award+"</p>";
        obj.innerHTML=strContent;
        $("dvparenttask").appendChild(obj);
    }
    if(target=="送出一朵小红花")
    {
        $("ptasksendhonghua").style.display="block";
        obj.style.width="415px"
    }
    else
    {
         $("ptasksendhonghua").style.display="none";
         obj.style.width="170px"
    }
    obj.style.bottom=arrTaskBottom[id]+"px";
    
    return;
}

function disAppearTaskInfo()
{
    var obj=$("dvtaskitem");
    if(obj)
    {
        AddClassName(obj,"task-item hide");
    }
    return;
}

function ChangeTaskStatic()
{
	jQuery(".task-img img").attr("src",imageUrl+'/img/room/task-stop.gif');
	
    var obj=$("dvparenttask");
    if(GetClassName(obj)=="task")
    {
        AddClassName(obj,"task hide");
    }
    else
    {
        AddClassName(obj,"task");
    }
}

function CloseTaskDisplay()
{
	AddClassName($("dvparenttask"),"task hide");
}

function GetTaskAward(taskid)
{
	jQuery.getJSON(
			"index_ajax.php?action=600020&taskid="+taskid+"&randID="+Math.random(),
			function(obj){
				if(obj.confirm==100)
                {
                    var dl=$("dltask"+taskid);
                    if(dl)
                    {
                        AddClassName(dl,"received");
                        var dt=dl.getElementsByTagName("dt");
                        if(dt && dt[0])
                        {
                            dt[0].innerHTML=dt[0].innerHTML.replace('<a href="#">',"<span>").replace("</a>","</span>");
                        }
                        var dd=dl.getElementsByTagName("dd");
                        if(dd && dd[0])
                        {
                            dd[0].innerHTML="已领取";
                        }
                    }
                    if(obj.data.type==0)
                    {
                       var spobj=$("spgift101");
                       if(spobj)
                       {
                           spobj.innerHTML=parseInt(spobj.innerHTML)+obj.data.count;
                       }
                       else
                       {
                           var nothing=$("lipacknothing");
                           if(nothing)
                           {
                               ClearChildNodes(nothing);
                           }
                           var li=document.createElement("li");
                           li.setAttribute("ispackage", 1);
                           li.setAttribute("price", 50);
                           li.setAttribute("gid", 101);
                           li.setAttribute("giftname", "小红花");
                           addEvent(li,"click",function(){giftchangebg(li,1);});
                           var strContent=createFlowInPackageNode(obj.data.count);
                           li.innerHTML=strContent;
                           addGiftInPackage(li);
                           //$("dvsendgift7").appendChild(li);
                       }
                       var newprops=$("spnewprops");
                       if(newprops)
                       {
                           AddClassName(newprops,"new-props"); 
                           ClearNewProps(newprops);
                       }
                    }
                    else
                    {
                       $("spusercoins").innerHTML=obj.data.usercoins;
                       objUser.usercoins=obj.data.usercoins;
                    }
                   
                } else if (obj.confirm == 2)
                {
					document.getElementById('task_info').style.display = 'block';

					return ;
                }
                else
                {
                    alert("领取失败");
                }
			}
	);

}

function ClearNewProps(newprops)
{
    if(newprops)
    {
          var timeoutnewpop=setTimeout(function(){
            AddClassName(newprops,"new-props hide");
            clearTimeout(timeoutnewpop);
            },10000)   
    }
}
function setAwardStatic(state){
    awardstatic=state;
}
function GetDayAward()
{
    if(awardstatic==0)
    {
        PullboxUncomplete();
        return;
    }
    
    /// 优化 by niugh
    jQuery.getJSON(
			"index_ajax.php?action=600022&randID="+Math.random(),
			function(obj){
				if(obj.confirm==100)
                {
                    Pullboxcomplete();
                    if(obj.data.count>=10){
                               document.getElementById('dvdaygiftparent').style.display='none';    
                               return;
                           }
                    obj.data.count=obj.data.count+1;
				    thisMovie("timeid").asGetDayAward(obj.data.count);
				    awardstatic=0;
                   
                       var spobj=$("spgift101");
                       if(spobj)
                       {
                           spobj.innerHTML=parseInt(spobj.innerHTML)+10;
                       }
                       else
                       {
                           var nothing=$("lipacknothing");
                           if(nothing)
                           {
                               ClearChildNodes(nothing);
                           }
                           var li=document.createElement("li");
                           li.setAttribute("ispackage", 1);
                           li.setAttribute("price", 50);
                           li.setAttribute("gid", 101);
                           li.setAttribute("giftname", "小红花");
                           addEvent(li,"click",function(){giftchangebg(li,1);});
                           var strContent=createFlowInPackageNode(10);
                           li.innerHTML=strContent;
                           addGiftInPackage(li);

                       }
                       var newprops=$("spnewprops");
                       if(newprops)
                       {
                           AddClassName(newprops,"new-props"); 
                           ClearNewProps(newprops);
                       }

                   
                }
                else if(obj.confirm==1)
                {
                    alert("领取失败");
                }
                else if(obj.confirm==2)
                {
                    PullboxHadFail();
                }
                else if(obj.confirm==3)
                {
                    alert("一天最多领取10次");
                }else if(obj.confirm==4){
                    alert("登录后才能领取");
                }
			}
	);
}

function PullboxHadFail()
{
    var obj=$("pBox1");
    var position=getElementPos($("dvdaygiftparent"));
    if(obj)
    {
        AddClassName(obj,"pull-box");
    }
    else
    {
        obj=document.createElement("div");
        obj.id="pBox1";
        AddClassName(obj,"pull-box");
        var strContent="";
        strContent+='<div class="pull-box-tit">提示<a href="###" onclick="AddClassName($(\'pBox1\'),\'pull-box hide\')">&times;</a>';
        strContent+='</div>';
        strContent+='<div class="pull-box-container">';
        strContent+='<ul>';
        strContent+='<li>您五分钟内已在其他房间内领取过奖励了哦，不能重复领取~~</li>';
        strContent+='</ul>';
        strContent+='</div>';
        obj.innerHTML=strContent;
        obj.style.top=(position.y+30)+"px";
        obj.style.left=(position.x-158)+"px";
        document.body.appendChild(obj);
    }
    return;
}

function TaskHadFail()
{
    var obj=$("pBox1");
    var position=getElementPos($("dvdaygiftparent"));
    if(obj)
    {
        AddClassName(obj,"pull-box");
    }
    else
    {
        obj=document.createElement("div");
        obj.id="pBox1";
        AddClassName(obj,"pull-box");
        var strContent="";
        strContent+='<div class="pull-box-tit">提示<a href="###" onclick="AddClassName($(\'pBox1\'),\'pull-box hide\')">&times;</a>';
        strContent+='</div>';
        strContent+='<div class="pull-box-container">';
        strContent+='<ul>';
        strContent+='<li>>您还未进行安全验证，请先到<a href="/?action=300001&r=2">安全中心</a>进行安全验证</li>';
        strContent+='</ul>';
        strContent+='</div>';
        obj.innerHTML=strContent;
        obj.style.top=(position.y+30)+"px";
        obj.style.left=(position.x-158)+"px";
        document.body.appendChild(obj);
    }
    return;
}

function PullboxUncomplete()
{
    var obj=$("pBox2");
    var position=getElementPos($("dvdaygiftparent"));
    if(obj)
    {
        AddClassName(obj,"pull-box");
    }
    else
    {
        obj=document.createElement("div");
        obj.id="pBox2";
        AddClassName(obj,"pull-box");
        var strContent="";
        strContent+='<div class="pull-box-tit">提示<a href="###" onclick="AddClassName($(\'pBox2\'),\'pull-box hide\')">&times;</a>';
        strContent+='</div>';
        strContent+='<div class="pull-box-container">';
        strContent+='<strong>任务未完成</strong>';
        strContent+='<ul>';
        strContent+='<li>进入房间观看<i>5分钟</i>直播即可获得<i>10朵小红花</i>奖励。</li>';
        strContent+='</ul>';
        strContent+='</div>';
        obj.innerHTML=strContent;
        obj.style.top=(position.y+65)+"px";
        obj.style.left=(position.x-158)+"px";
        document.body.appendChild(obj);
    }
    return;
}

function Pullboxcomplete()
{
    var obj=$("pBox3");
    var position=getElementPos($("dvdaygiftparent"));
    if(obj)
    {
        AddClassName(obj,"pull-box");
    }
    else
    {
        obj=document.createElement("div");
        obj.id="pBox3";
        AddClassName(obj,"pull-box");
        var strContent="";
        strContent+='<div class="pull-box-tit">提示<a href="###" onclick="AddClassName($(\'pBox3\'),\'pull-box hide\')">&times;</a>';
        strContent+='</div>';
        strContent+='<div class="pull-box-container">';
        strContent+='<strong>成功领取10朵小红花！</strong>';
        strContent+='<ul>';
        strContent+='<li>请在包裹中查看您的奖励。继续在线还可领取，每日最多领取<i>十次</i>哦。</li>';
        strContent+='</ul>';
        strContent+='</div>';
        obj.innerHTML=strContent;
        obj.style.top=(position.y+30)+"px";
        obj.style.left=(position.x-158)+"px";
        document.body.appendChild(obj);
    }
    return;
}

var awardstatic=0;
function DayCountdown()
{
    var maxTime=300;
    var obj= $("spdaygifttime");
    var varDayGift=setInterval(function(){
        obj.innerHTML=CountDownToStr(maxTime);
        maxTime--;
        if(maxTime<0)
        {
            clearInterval(varDayGift);
            $("imggetward").src=imageUrl+"/img/room/pull_reward.gif"
            awardstatic=1;
        }
    },1000)
}
function CountDownToStr(time)
{
    var min=parseInt(time/60);
    var sec=time%60;
    if(sec<10)
    {
        sec="0"+sec;
    }
    return "0"+min+":"+sec;
    
}

//比较js对象是否相等
function equalsTest(objA,objB){
	if(objA == objB){
		return true; 
	}
	if(typeof(objA)=="undefined"||objA==null||typeof(objA)!="object" || typeof(objB)=="undefined"||objB==null||typeof(objB)!="object") {
		return false;
	}
	var length = 0; var length1=0; 
	for(var ele in objA) { 
		length++; 
	} 
	for(var ele in objB) { 
		length1++; 
	} 
	if(length!=length1)
		return false;
	if(objA.constructor == objB.constructor){
		for(var ele in objA){
			if(typeof(objA[ele])=="object") { 
				if(!equalsTest(objA[ele],objB[ele])) return false;
			}else if(typeof(objA[ele])=="function"){
				if(!equalsTest(objA[ele].toString(),objB[ele].toString())) return false;
			}else if(objA[ele]!=objB[ele]) 
				return false; 
		}
		return true; 
	}
	return false; 
}


//过滤敏感词汇
function replace_sensitive_words(str,replaceStr){
	var len=dirtyWord.length;
	var len1="";
	for(var i = 0 ; i < len; i ++){
		var ss='';
		len1 = dirtyWord[i].length;
		for(var j=0 ; j < len1 ; j++){
			ss+=dirtyWord[i].charAt(j)+'.{0,2}';
		}
		var pregt = ss.substring(0,ss.length-6);
		var raRegExp = new RegExp(pregt,"i");
   		str = str.replace(raRegExp,replaceStr); 
   		
	}
	return str;
}
//过滤敏感词汇其他
function replace_sensitive_words_other(str,replaceStr){
	var len=dirtyWordOther.length;
	var len1="";
	for(var i = 0 ; i < len; i ++){
		var ss='';
		len1 = dirtyWordOther[i].length;
		for(var j=0 ; j < len1 ; j++){
			ss+=dirtyWordOther[i].charAt(j)+'.{0,2}';
		}
		var pregt = ss.substring(0,ss.length-6);
		var raRegExp = new RegExp(pregt,"i");
   		str = str.replace(raRegExp,replaceStr); 
   		
	}
	return str;
}
function createFlowInPackageNode(num){
    var strContent='<div id="dvpage" onmouseover="DisplayGiftTitle(event,\'小红花\',\'每个对方可获得50贝壳的富豪等级提升\');" onmouseout="NoneGiftTitle();" style="background-image:url('+imageUrl+'/img/red_follow.gif?v=800017);cursor:pointer;display:inline-block;background-position:-0px 0px"><span id="spgift101" class="follow-num">'+num+'</span></div><span></span>';
    return strContent;
}
function createSinglePackageNode(gid,num){
    var strContent='';
    switch(gid){
        case 6:
            strContent+='<div style="background-image:url('+imageUrl+'/img/gift.png?v=800029);cursor:pointer;display:inline-block;background-position:-240px 0px" onmouseout="NoneGiftTitle();" onmouseover="DisplayGiftTitle(event,\'幸运红玫瑰\',\'获得22贝壳，赠送者获得100贝壳的富豪等级提升(上限200个)\');" id="dvpage"><span class="follow-num" id="spgift6">'+num+'</span></div><span></span>';
            break;
        case 2:
             strContent+='<div style="background-image:url('+imageUrl+'/img/gift.png?v=800029);cursor:pointer;display:inline-block;background-position:-280px 0px" onmouseout="NoneGiftTitle();" onmouseover="DisplayGiftTitle(event,\'幸运棒棒糖\',\'获得22贝壳，赠送者获得100贝壳的富豪等级提升(上限200个)\');" id="dvpage"><span class="follow-num" id="spgift2">'+num+'</span></div><span></span>';
             break;
    }
    return strContent;
}
function singlePackageNotify(gid,giftname,price,count){
    var spobj=$("spgift"+gid);
    if(spobj){
        var sum=parseInt(spobj.innerHTML)+count;
        spobj.innerHTML=sum;  
    }else{
        var nothing=$("lipacknothing");
        if(nothing){
            ClearChildNodes(nothing);
        }
            var li=document.createElement("li");
            li.setAttribute("ispackage", 1);
            li.setAttribute("price", price);
            li.setAttribute("gid", gid);
            li.setAttribute("giftname", giftname);
            addEvent(li,"click",function(){giftchangebg(li,1);});
            var strContent=createSinglePackageNode(gid,count);
            li.innerHTML=strContent;
            addGiftInPackage(li);

    }
    var newprops=$("spnewprops");
    if(newprops){
        AddClassName(newprops,"new-props"); 
        ClearNewProps(newprops);
    }
}
function var_dump(myObject) {  
      var s = "";  
      for (var property in myObject) {  
       s = s + "\n "+property +": " + myObject[property] ;  
      }  
      alert(s);  
}

function is_sensitive_words_other(strContent){
    var len=dirtyWordOther.length;
	var len1="";
        var flag=false;
	for(var i = 0 ; i < len; i ++){
		var ss='';
		len1 = dirtyWordOther[i].length;
		for(var j=0 ; j < len1 ; j++){
			ss+=dirtyWordOther[i].charAt(j)+'.{0,2}';
		}
		var pregt = ss.substring(0,ss.length-6);
		var raRegExp = new RegExp(pregt,"i");
   		if(raRegExp.test(strContent)){
                    flag=true;
                    break;
                }
	}
	return flag;
}
